package com.lianqi.emcpframework.ddd.gencode.define;

import java.util.Map;

import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;

import com.google.common.collect.Maps;

/**
 * @program
 * @ClassName TypeCollector
 * @description: 类型装换控制器
 * @author: sky
 * @create: 2019-06-13 14:32
 */
public final class TypeCollector {
    private final Map<String, TypeElement> typeElements = Maps.newHashMap();

    /**
     * @Description: 从运行环境中拿到 类型标准名称和类型的对应关系
     * 
     * @param roundEnv
     * @date: 2019-06-13 14:33
     * @auther: sky
     */
    public void syncForm(RoundEnvironment roundEnv) {
        for (Element element : roundEnv.getRootElements()) {
            if (element instanceof TypeElement) {
                String name = ((TypeElement)element).getQualifiedName().toString();
                this.typeElements.put(name, (TypeElement)element);
            }
        }
    }

    public TypeElement getByName(String name) {
        return this.typeElements.get(name);
    }
}
